package com.saver.view.formatter;

import com.github.mikephil.charting.utils.ValueFormatter;

import java.text.DecimalFormat;
import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;

/**
 * Created by HeRGoS on 26/04/2015
 */
public class PercentValueFormatter implements ValueFormatter {

    private NumberFormat format;

    public PercentValueFormatter() {
        format = NumberFormat.getPercentInstance();
        DecimalFormatSymbols symbols = new DecimalFormatSymbols();
        symbols.setDecimalSeparator('.');
        ((DecimalFormat) format).setDecimalFormatSymbols(symbols);
        format.setMinimumFractionDigits(2);
        format.setMaximumFractionDigits(2);
    }

    @Override
    public String getFormattedValue(float value) {
        return format.format(value / 100);
    }
}
